$(document).ready(function () {
    prependHeaderSection();
    appendFooterSection();
    //Navi hover
    $('li.bigd-dropdown').hover(function () {
        $(this).find('.bigd-dropdown-menu').first().stop(true, true).delay(50).fadeIn();
    }, function () {
        $(this).find('.bigd-dropdown-menu').first().stop(true, true).delay(50).fadeOut();
    });

    $('.bigd-collapsed').click(function () {
        $('#bigd-coll').toggle();
        var display = $('#bigd-coll').css("display");
        if (display == 'block') {
            $('.bigd-navbar').css("height", "200px");
        } else {
            $('.bigd-navbar').css("height", "30px");
        }

    });
});

var bigd_site = "http://bigd.big.ac.cn/";

function prependHeaderSection() {
    $('head').append("<link rel='stylesheet' type='text/css' href='" + bigd_site + "static/css/page.min.css'>");
    var header = "<header>" +
        "<div class='bigd-container'>" +
        "<nav class='bigd-navbar-default bigd-navbar'>" +
        "<div class='bigd-navbar-header'>" +
        "<button type='button' class='bigd-navbar-toggle bigd-collapsed'> <span class='bigd-sr-only'>Toggle navigation</span>" +
        "<span class='bigd-icon-bar'></span>" +
        "<span class='bigd-icon-bar'></span> " +
        "<span class='bigd-icon-bar'></span> " +
        "</button> " +
        "<a href='" + bigd_site + "' class='bigd-navbar-brand'><img src='" + bigd_site + "static/image/bigd-logo.png' /></a>" +
        "</div>" +

        "<div class='bigd-collapse bigd-navbar-collapse' id='bigd-coll'>" +
        "<ul class='bigd-nav bigd-navbar-nav bigd-navbar-right'>" +
        "<li><a href='" + bigd_site + "databases'> Databases</a></li>" +
        "<li><a href='" + bigd_site + "tools'>Tools</a></li> " +
        "<li><a href='" + bigd_site + "publications'>Publications</a></li>" +
        "<li><a href='" + bigd_site + "about'>About</a></li>" +
        "</ul>" +
        "</div>" +
        "</nav>" +
        "</div>" +
        "</header>";
    $("body").prepend(header);
}

function appendFooterSection() {
    var myDate = new Date();
    var year = myDate.getFullYear();
    var footer = "" +
        "<footer class='bigd-footer' style='font-family: Arial'>" +
        "<div class='bigd-container'><div class='bigd-panel bigd-panel-default'>" +
        "<div class='bigd-panel-body'>" +
        "<div class='bigd-row'> " +
        "<div class='bigd-col-md-3'> " +
        "<a href='" + bigd_site + "'><img src='" + bigd_site + "static/image/bigd-logo-blue.png'  style='margin-top: 15px'/></a> " +
        "<ul class='bigd-list-unstyled'> " +
        "<li><a href='" + bigd_site + "about'>About BIGD</a></li> " +
        "<li><a href='" + bigd_site + "mission'>Mission</a></li> " +
        "<li><a href='" + bigd_site + "board'>Advisory Board</a></li> " +
        "<li><a href='" + bigd_site + "structure'>Organizational Structure</a></li> " +
        "<li><a href='" + bigd_site + "history'>History</a></li> " +
        "</ul> " +
        "</div> " +

        "<div class='bigd-col-md-2'> " +
        "<h3>Resources</h3> " +
        "<ul class='bigd-list-unstyled'> " +
        "<li><a href='" + bigd_site + "databases'>Databases</a></li> " +
        "<li><a href='" + bigd_site + "tools'>Tools</a></li> " +
        "</ul> " +
        "</div> " +

        "<div class='bigd-col-md-2'> " +
        "<h3>Research</h3> " +
        "<ul class='bigd-list-unstyled'> " +
        "<li><a href='" + bigd_site + "research'>Topics & Projects</a></li> " +
        "<li><a href='" + bigd_site + "publications'>Publications</a></li> " +
        "</ul> " +
        "</div> " +

        "<div class='bigd-col-md-2'> " +
        "<h3>Featured</h3> " +
        "<ul class='bigd-list-unstyled'> " +
        "<li><a href='http://databasecommons.org' target='_blank'>Database Commons</a></li> " +
        "<li><a href='http://gsa.big.ac.cn' target='_blank' title='Genome Sequence Archive'>GSA</a></li> " +
        "<li><a href='http://ic4r.org' target='_blank' title='Information Commons for Rice'>IC4R</a></li>" +
        "<li><a href='http://dnamethylome.org' target='_blank' title='Methylation DataBank'>MethBank</a></li> " +
        "<li><a href='http://vcg.cbi.ac.cn' target='_blank' title='Virtual Chinese Genome Database'>VCGDB</a></li> " +
        "</ul> " +
        "</div> " +

        "<div class='bigd-col-md-2'> " +
        "<h3>About Us</h3> " +
        "<ul class='bigd-list-unstyled'> " +
        "<li><a href='" + bigd_site + "people'>People</a></li> " +
        "<li><a href='" + bigd_site + "collaborations'>Collaborations</a></li> " +
        "<li><a href='" + bigd_site + "funding'>Funding</a></li> " +
        "<li><a href='" + bigd_site + "contact'>Contact Us</a></li> " +
        "</ul> " +
        "</div> " +
        "</div> " +

        "<hr class='footer-hr'>" +
        "<p class='bigd-text-muted'>" +
        "Copyright &copy; " + year + " BIG Data Center, <a href='http://english.big.cas.cn' target='_blank'>Beijing Institute of Genomics</a>, <a href='http://english.cas.cn' target='_blank'>Chinese Academy of Sciences</a><br/>" +
        "No.1 Beichen West Road, Chaoyang District, Beijing 100101, China" +
        "</p>" +
        "</div>" +
        "</div>" +
        "</div>" +
        "</footer>";
    $("body").append(footer);
}
